var app = getApp()
Page({
  //数据
  data:{
      userInfo: {},
      state1: "state1",
      state2: "state1",
  },

  pay:function () {
    var timestamp = Date.parse(new Date());
    console.log(timestamp);
    wx.requestPayment({
      'appId': 'wx04392d5e4bfbe99a',
      'timeStamp': '1491897119000',
      'nonceStr': '5K8264ILTKCH16CQ2502SI8ZNMTM67VS',
      'package': 'prepay_id=wx2017033010242291fcfe0db70013231072',
      'signType': 'MD5',
      'paySign': '5222F10203BF50A1023BBB72467595D6',
      'success':function(res){

      },
      'fail':function(res){
        
      }
    })
  },

  type1:function () {
      var state = this.data.state1;
      console.log(state);
      if (state == "state1") {
        this.setData({
          state1: "state2",
          state2: "state1"
        })
      } else {
        this.setData({
          state1: "state1"
        })
      }
  },

  type2:function () {
      var state = this.data.state2;
      console.log(state);
      if (state == "state1") {
        this.setData({
          state2: "state2",
          state1: "state1"
        })
      } else {
        this.setData({
          state2: "state1"
        })
      }
  },

  //页面渲染完成后动作
  onLoad: function () {
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
      console.log(userInfo);
    })
  }
})